<script setup lang="ts">
import { ref, onMounted } from 'vue'
import http from '@/tools/http'
const props = defineProps(["menuCode"])

const iframeSrc = ref<string>("")

onMounted(() => {
    getMenuInfo()
})

function getMenuInfo() {
    const request = {
        menuCode: props.menuCode
    }
    http.post("/menu", request).then(({ data }) => {
        if (data.code === "0") {
            if (data.data.menuUrl.substr(0, 4) === "http") {
                iframeSrc.value = data.data.menuUrl
            } else {
                const host = location.protocol + "\/\/" + location.host
                if (data.data.menuUrl.substr(0, 1) === "/") {
                    iframeSrc.value = host + data.data.menuUrl
                } else {
                    iframeSrc.value = host + "/" + data.data.menuUrl
                }
                console.log(iframeSrc.value)
            }
        }
    })
}

</script>

<template>
    <div class="flame-container">
        <iframe :src="iframeSrc" width="100%" height="100%" frameborder="0" scrolling="no">
        </iframe>
    </div>
</template>

<style scoped></style>